//
//  LSWaitForMeToExamineTableViewCell.m
//  LaSaCivilAffairsDepartment
//
//  Created by 聂志康 on 2018/12/22.
//  Copyright © 2018 wpkj. All rights reserved.
//

#import "LSWaitForMeToExamineTableViewCell.h"

@interface LSWaitForMeToExamineTableViewCell ()
@property (nonatomic, strong) UILabel *mainTitleLabel;
@property (nonatomic, strong) UILabel *mainDetailLabel;
@property (nonatomic, strong) UILabel *mainDateLabel;
@end

@implementation LSWaitForMeToExamineTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self.contentView addSubview:self.mainTitleLabel];
        [self.contentView addSubview:self.mainDetailLabel];
        [self.contentView addSubview:self.mainDateLabel];
    }
    return self;
}

- (void)setMainTitleText:(NSString *)mainTitleText {
    _mainTitleText = mainTitleText;
    self.mainTitleLabel.text = mainTitleText;
}

- (void)setMainDetailText:(NSString *)mainDetailText {
    _mainDetailText = mainDetailText;
    NSMutableParagraphStyle *paragraphStyle = [NSMutableParagraphStyle new];
    paragraphStyle.lineSpacing = 4 - (self.mainDetailLabel.font.lineHeight - self.mainDetailLabel.font.pointSize);
    NSMutableDictionary *attributes = [NSMutableDictionary dictionary];
    [attributes setObject:paragraphStyle forKey:NSParagraphStyleAttributeName];
    self.mainDetailLabel.attributedText = [[NSAttributedString alloc] initWithString:mainDetailText attributes:attributes];
}

- (void)setMainDateText:(NSString *)mainDateText {
    _mainDateText = mainDateText;
    self.mainDateLabel.text = mainDateText;
}

- (void)layoutSubviews {
    [super layoutSubviews];
    WS
    [self.mainTitleLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.contentView.mas_left).with.offset(15);
        make.top.equalTo(weakSelf.contentView.mas_top).with.offset(20);
    }];
    [self.mainDetailLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.contentView.mas_left).with.offset(15);
        make.top.equalTo(weakSelf.mainTitleLabel.mas_bottom).with.offset(10);
        make.right.equalTo(weakSelf.contentView.mas_right).with.offset(-15);
    }];
    [self.mainDateLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(weakSelf.contentView.mas_right).with.offset(-20);
        make.bottom.equalTo(weakSelf.mainTitleLabel.mas_bottom);
    }];
}

- (UILabel *)mainTitleLabel {
    if (!_mainTitleLabel) {
        _mainTitleLabel = [[UILabel alloc] init];
        _mainTitleLabel.textColor = hexColor(666666);
        _mainTitleLabel.font = [UIFont fontWithName:@"SourceHanSansCN-Regular" size:12];
    }
    return _mainTitleLabel;
}

- (UILabel *)mainDetailLabel {
    if (!_mainDetailLabel) {
        _mainDetailLabel = [[UILabel alloc] init];
        _mainDetailLabel.textColor = hexColor(666666);
        _mainDetailLabel.font = [UIFont fontWithName:@"SourceHanSansCN-Regular" size:9];
        _mainDetailLabel.numberOfLines = 2;
    }
    return _mainDetailLabel;
}

- (UILabel *)mainDateLabel {
    if (!_mainDateLabel) {
        _mainDateLabel = [[UILabel alloc] init];
        _mainDateLabel.textColor = hexColor(666666);
        _mainDateLabel.font = [UIFont fontWithName:@"SourceHanSansCN-Regular" size:9];
        _mainDateLabel.textAlignment = NSTextAlignmentRight;
    }
    return _mainDateLabel;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
